<?PHP
include("settings.php");
include("connect.php");
include("functions.php");
limits();
include("queries.php");
$result = $db->query($query15);
include("header.php");

echo '<div id="header">
<ul id="tabnav">
	<li><a href="index.php">Home</a></li>
	'.($settings['personaljournal'] == true ? "<li><a href=\"journal.php\" class=\"active\">Personal Journal</a></li>" : "").'
	'.($settings['personaltransactions'] == true ? "<li><a href=\"transactions.php\">Personal Transactions</a></li>" : "").'
	'.($settings['corpjournal'] == true ? "<li><a href=\"corpj.php\">Corporate Journal</a></li>" : "").'
	'.($settings['corptransactions'] == true ? "<li><a href=\"corpt.php\">Corporate Transactions</a></li>" : "").'
	<li><a href="overview.php?wallet=personal'.(isset($_GET['typeID']) && !empty($_GET['typeID']) ? "&typeID=".$_GET['typeID']."" : "").'">Overview</a></li>
	<li id="time">'.get_current_time().'</li>
</ul>
</div>';

echo '
<table id="wrapper" border="0" cellpadding="0" cellspacing="0">
	<tr>
		<td colspan="7">';
echo '
		<table align="right"><tr>
		<td>
		</td>
		<td>
		<ul id="butnav">
		<li><a href="?">Reset</a></li>
		<li><a href="?settings=save">Save</a></li>
		<li><a href="update.php?wallet=personaljournal">Update This Wallet</a></li>
		</ul>
		</td>
		<td><form action="" method="get">
		'.get_input(images).'
Images &nbsp;
			<select name="images" onChange="this.form.submit();">
			<option value="on"'.($settings['images'] == 'on' ? " selected" : "").'>On</option>
			<option value="off"'.($settings['images'] == 'off' ? " selected" : "").'>Off</option>
			</select>
		</form></td>
		<td><form action="" method="get">
		'.get_input(limit).'
Display &nbsp;
			<select name="limit" onChange="this.form.submit();">
			<option value="'.$limit.'" selected>'.$limit.'</option>
			<option value="40">Forty</option>
			<option value="30">Thirty</option>
			<option value="20">Twenty</option>
			<option value="15">Fifteen</option>
			<option value="10">Ten</option>
			</select>
		</form></td>
		</tr></table>
		</td>
	</tr>
	<tr><td colspan="6">
	<div style="float:left;width:300px">
	<form action="" method="get">
Reference &nbsp;
	'.(isset($_GET['query']) && !empty($_GET['query']) ? "<input type=\"hidden\" name=\"query\" value=\"".$_GET['query']."\" />" : "").'
			<select name="refTypeID" onChange="this.form.submit();">
			<option value=""'.(empty($_GET['transactionType']) OR !isset($_GET['transactionType']) ? " selected" : "").'>All</option>
			'.get_reference_selects().'
			</select>
		</form>
	</div>
	<div style="float:left;width:350px">
	'.((isset($_GET['query']) && !empty($_GET['query'])) ? 
		"<ul id=\"xnav\"><li><a href=\"?".(isset($_GET['refTypeID']) && !empty($_GET['refTypeID']) ? "&refTypeID=".$_GET['refTypeID']."" : "")."\">X</a></li></ul>".$_GET['query'].""
		 : 
		 "<form action=\"\" method=\"get\">
&nbsp;Character &nbsp;
		".(isset($_GET['refTypeID']) && !empty($_GET['refTypeID']) ? "<input type=\"hidden\" name=\"refTypeID\" value=\"".$_GET['refTypeID']."\" />" : "")."
        <input type=\"text\" name=\"query\" style=\"width:140px;\" />
		<script>
            new CAPXOUS.AutoComplete(\"query\", function() {
                return \"autocomplete.php?type=query&wallet=personal&typing=\" + this.text.value
            });
			clearCurrentLink();
        </script>
		</form>").'
	</div>
	</td></tr>
	<tr><td colspan="6">
	'.pagination($db->foundRows).'
	</td></tr>
	<tr>
		<td id="row" style="padding-bottom:5px;">Date Time</td>
		<td id="row" style="padding-bottom:5px;">Reference</td>
		<td id="row" style="padding-bottom:5px;">Description</td>
		<td id="row" style="padding-bottom:5px;">Amount</td>
		<td id="row" style="padding-bottom:5px;">Balance</td>
		<td id="row" style="padding-bottom:5px;">Reason</td>
	</tr>';
	
if (mysql_num_rows($result) == 0) {
	echo '<tr><td id="row" colspan="6" style="text-align:center;height:75px;">
			No journal entries found.
		  </td></tr>';
	}
while ($row = $db->fetch_assoc($result)) {
//split datetime
$datetime = explode(" ", $row[date]);
if (get_transaction_data($row[argName1],wallet)) {} else $transaction_data = array(quantity => "", typeID => "0");
echo '
	<tr onmouseover="setPointer(this, 1, \'over\', \''.$settings['normal'].'\', \''.$settings['rollover'].'\', \''.$settings['click'].'\');" onmouseout="setPointer(this, 1, \'out\', \''.$settings['normal'].'\', \''.$settings['rollover'].'\', \''.$settings['click'].'\');" onmousedown="setPointer(this, 1, \'click\', \''.$settings['normal'].'\', \''.$settings['rollover'].'\', \''.$settings['click'].'\');">
		<td id="row" bgcolor="'.$settings['normal'].'">'.$datetime[0].'<br />'.$datetime[1].'</td>
		<td id="row" bgcolor="'.$settings['normal'].'">'.get_reference($row[refTypeID]).'</td>
		<td id="row" bgcolor="'.$settings['normal'].'">'.get_description($row[refTypeID],$row[ownerName1],$row[ownerID1],$row[ownerName2],$row[ownerID2],$row[argName1],$row[argID1],$row[amount],$transaction_data[quantity],$transaction_data[typeID],transactions).'</td>
		<td id="row" style="text-align:right;padding-right:5px;color: '.($row[transactionType] == 'buy' ? "red" : "green").';" bgcolor="'.$settings['normal'].'">'.number_format($row[amount], 2, '.', ',').'</td>
		<td id="row" style="text-align:right;" bgcolor="'.$settings['normal'].'">'.number_format($row[balance], 2, '.', ',').'</td>
		<td id="row" bgcolor="'.$settings['normal'].'">
		&nbsp;'.$row[reason].'
		</td>
	</tr>
';
}// end Row while
echo '<tr><td colspan="6">'.pagination($db->foundRows).'</td></tr>';
echo '
</table>
';


?>